package com.seu.clab.farm.model.dao.mapper;

import com.seu.clab.farm.model.dao.entity.Account;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface AccountMapper extends Mapper<Account> {

    @Select("select name from account where account_id='${accountId}'")
    String getNameById(String accountId);

    @Select("select account_id as accountId, name, phone, email, identify, " +
            "avatar from account where account_id='${id}'")
    Map<String,Object> getAccountInfo(String id);

    @Select("select account_id as accountId,name,phone,email,avatar,identify from account " +
            "where name is not null " +
            "limit ${pageIndex},20")
    List<Map<String,Object>> getAccountList(Integer pageIndex);

    @Select("select count(*) from account")
    Integer getAccountCount();


    @Select("select account_id as accountId,name,phone,email,avatar,identify from account " +
            "where name like '%${name}%'")
    List<Map<String,Object>> getSearchAccount(String name);

}